<template>
	<view class="page">
		<nav-bar :shadow="false">申请资深合伙人</nav-bar>
		<!-- 公共组件-每个页面必须引入 -->
		<public-module></public-module>
		<view class="title">
			任务进度
		</view>
		<view class="progress_box">
			<view class="progress_item">
				<!-- <view class="circle">
					<view class="pie_left">
						<view class="left"></view>
					</view>
					<view class="pie_right">
						<view class="right"></view>
					</view>
					<view class="mask">4/5</view>
				</view> -->
				<zwp-ring-timing mode="chart" :activeColor="'#7ac23c'" :value="chartValue1">
					<text>{{progressinfo.directSubordinateCount}}/{{progressinfo.directSubordinateCountTarget}}</text>
				</zwp-ring-timing>
				<text class="num">直推人数</text>
			</view>
			<view class="progress_item">
				<zwp-ring-timing mode="chart" :activeColor="'#eca10d'" :value="chartValue2">
					<text class="yellow">{{progressinfo.groupSubordinateCount}}/{{progressinfo.groupSubordinateCountTarget}}</text>
				</zwp-ring-timing>
				<text class="num">团队人数</text>
			</view>
		</view>
		<view class="title">
			合伙人特权
		</view>
		<view class="privilege_box">
			<view class="item">
				<image src="../../../static/icon/welfare/ic_fuli_a.png" mode="aspectFill"></image>
				<text>等级特权</text>
			</view>
			<view class="item">
				<image src="../../../static/icon/welfare/ic_fuli_a.png" mode="aspectFill"></image>
				<text>等级特权</text>
			</view>
			<view class="item">
				<image src="../../../static/icon/welfare/ic_fuli_a.png" mode="aspectFill"></image>
				<text>等级特权</text>
			</view>
			<view class="item">
				<image src="../../../static/icon/welfare/ic_fuli_a.png" mode="aspectFill"></image>
				<text>等级特权</text>
			</view>
			<view class="item">
				<image src="../../../static/icon/welfare/ic_fuli_a.png" mode="aspectFill"></image>
				<text>等级特权</text>
			</view>
			<view class="item">
				<image src="../../../static/icon/welfare/ic_fuli_a.png" mode="aspectFill"></image>
				<text>等级特权</text>
			</view>
		</view>
		<view class="tips">
			完成邀请任务即可申请成为资深合伙人
		</view>

		<view class="buy_box" v-if="!progressinfo.completed" @click="onPageJump('/pagesMy/my/partner/applyPartner?level='+ 5)">
			或立即购买套餐升级
		</view>
	</view>
</template>
<script>
	import zwpRingTiming from '@/components/common/zwp-ring-timing/zwp-ring-timing.vue'
	export default {
		components: {
			zwpRingTiming
		},
		data() {
			return {
				chartValue1: 0,
				chartValue2: 0,
				progressinfo: {}
			};
		},
		//第一次加载
		onLoad(e) {
			this.loadData();
		},
		//页面显示
		onShow() {},
		//方法
		methods: {
			onPageJump(url) {
				uni.navigateTo({
					url: url
				});
			},
			loadData() {
				this.$http.get('api/mime/recommend/v1/task_progress').then(res => {
					this.progressinfo = res;
					if (res.directSubordinateCount > 0) {
						this.chartValue1 = (this.progressinfo.directSubordinateCount / this.progressinfo.directSubordinateCountTarget)*100
						console.log(this.chartValue1);
					} 
					if (res.groupSubordinateCount > 0) {
						this.chartValue2 = (this.progressinfo.groupSubordinateCount / this.progressinfo.groupSubordinateCountTarget)*100
					} 
				})
				
			}
		},
		//页面隐藏
		onHide() {},
		//页面卸载
		onUnload() {},
		//页面下来刷新
		onPullDownRefresh() {},
		//页面上拉触底
		onReachBottom() {},
		//用户点击分享
		onShareAppMessage(e) {
			return this.wxShare();
		}
	};
</script>
<style lang="scss" scoped>
	@import '@/style/mixin.scss';

	.page {
		background-color: #fff;
		min-height: 100vh;
	}

	.title {
		padding: 40rpx 32rpx 24rpx 32rpx;
		font-size: 32rpx;
		color: #333333;
		font-weight: bold;
	}

	.progress_box {
		padding: 22rpx 90rpx;
		margin: 0 32rpx;
		background-color: #f7f7f7;
		border-radius: 8rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;

		.progress_item {
			display: flex;
			align-items: center;

			text {
				font-size: 24rpx;
				color: $themeColor;
				font-weight: bold;
			}

			.yellow {
				color: #eca10d;
			}

			.num {
				margin-left: 24rpx;
				font-size: 24rpx;
				color: #333333;
			}
		}
	}

	.circle {
		width: 88rpx;
		display: inline-block;
		height: 88rpx;
		//margin: 20rpx;
		position: relative;
		background: #fff;
		border-radius: 50%;

		.pie_left,
		.pie_right {
			width: 88rpx;
			height: 88rpx;
			position: absolute;
			top: 0rpx;
			left: 0rpx;
		}

		.left {
			position: absolute;
			left: 0rpx;
			top: 0rpx;
			border-radius: 50%;
			background: #7ac23c;
			transform: rotate(-180rpx);
			width: 100%;
			height: 100%;
			transform: rotate(-180deg);
		}

		.right {
			position: absolute;
			left: 0rpx;
			top: 0rpx;
			border-radius: 50%;
			background: #7ac23c;
			transform: rotate(-180rpx);
			width: 100%;
			height: 100%;
			transform: rotate(-120deg);
		}

		.pie_left,
		.left {
			clip: rect(auto, 44rpx, auto, auto);
			/*clip:rect(0,100rpx,auto,0);*/
		}

		.pie_right,
		.right {
			clip: rect(0, auto, auto, 44rpx);
		}

		.mask {
			position: absolute;
			top: 4rpx;
			left: 4rpx;
			width: 80rpx;
			height: 80rpx;
			line-height: 80rpx;
			font-size: 18rpx;
			font-weight: 600;
			border-radius: 50%;
			background: #fff;
			color: #7ac23c;
			text-align: center
		}
	}

	.privilege_box {
		margin-top: 16rpx;
		display: flex;
		flex-wrap: wrap;

		.item {
			margin-bottom: 40rpx;
			width: 33.33%;
			display: flex;
			flex-direction: column;
			align-items: center;

			image {
				width: 80rpx;
				height: 80rpx;
			}

			text {
				margin-top: 12rpx;
				font-size: 24rpx;
				color: #8e611f;
			}
		}
	}

	.tips {
		width: 456rpx;
		height: 57rpx;
		background-color: #f7f7f7;
		border-radius: 8rpx;
		font-size: 24rpx;
		color: #999999;
		margin: 0 auto;
		margin-top: 20rpx;
		line-height: 57rpx;
		text-align: center;
	}

	.buy_box {
		margin: 0 auto;
		margin-top: 40rpx;
		color: #7ac23c;
		text-align: center;
		font-size: 24rpx;
	}
</style>
